package cn.org.cute.ebocy.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * 时间格式处理类。
 */

public class StandDateFormat {
	
	/**
     * 时间格式：yyyy-MM-dd HH:mm:ss
     */
    public static final String FULL = "yyyy-MM-dd HH:mm:ss";
    
	/**
     * 时间格式：yy.MM.dd HH:mm
     */
    public static final String LONG = "yy.MM.dd HH:mm";
    
	/**
     * 时间格式：MM.dd HH:mm
     */
    public static final String MEDIUM = "MM.dd HH:mm";
    
	/**
     * 时间格式：yyyy-MM-dd
     */
    public static final String DATE = "yyyy-MM-dd";
    
    public static final String DATE2 = "yyyyMMdd";
    
	/**
     * 时间格式：HH:mm:ss
     */
    public static final String TIME = "HH:mm:ss";
    
	/**
     * 时间格式：HH:mm:ss
     */
    public static final String TIME2 = "HH:mm";
    
	/**
     * 时间格式：yyyy
     */
    public static final String YEAR = "yyyy";
    
	/**
     * 时间格式：yyyy-MM
     */
    public static final String MONTH = "yyyy-MM";
    
    public static final String MONTH2 = "yyyyMM";
    
	/**
     * 时间格式：MMM-d-yy
     */
    public static final String ENGNORMAL = "MMM-d-yy";
    
	/**
     * 时间格式：d-MMM-yy
     */
    public static final String ENGNORMAL2 = "d-MMM-yy";
    
	/**
     * 时间格式：MMM-yy
     */
    public static final String ENGMONTH = "MMM-yy";
    
	/**
     * 时间格式：MMM-d-yy
     */
    public static final String CHSNORMAL = "yyyy年M月d日";
    
    /**
     * 获得相应格式的SimpleDateFormat对象。
     * @param f 时间格式
     * @return SimpleDateFormat对象
     */
    public static SimpleDateFormat getFormat(String f){
    	return new SimpleDateFormat(f);
    }
    
    public static String fullFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(FULL).format(date);
    }
    
    public static String longFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(LONG).format(date);
    }    
        
    public static String mediumFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(MEDIUM).format(date);
    }
        
    public static String dateFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(DATE).format(date);
    }
    
    public static String dateFormat2(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(DATE2).format(date);
    }
    public static Date fullParse(String date){
    	Date d = null;
    	try{
    		d = new SimpleDateFormat(FULL).parse(date);
    	}
    	catch(Exception e){
    	}
    	return d;
    }
    public static Date dateParse(String date){
    	Date d = null;
    	try{
    		d = new SimpleDateFormat(DATE).parse(date);
    	}
    	catch(Exception e){
    	}
    	return d;
    }
    
    public static Date dateParse2(String date){
    	Date d = null;
    	try{
    		d = new SimpleDateFormat(DATE2).parse(date);
    	}
    	catch(Exception e){
    	}
    	return d;
    }
    public static String timeFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(TIME).format(date);
    }
    
    public static String yearFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(YEAR).format(date);
    }
    
    public static String monthFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(MONTH).format(date);
    }
    
    public static String monthFormat2(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(MONTH2).format(date);
    }
    
    public static String engNormalFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(ENGNORMAL,Locale.ENGLISH).format(date);
    }
    
    public static String engNormalFormat2(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(ENGNORMAL2,Locale.ENGLISH).format(date);
    }
    
    public static String engMonthFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(ENGMONTH,Locale.ENGLISH).format(date);
    }
    public static String chsNormalFormat(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(CHSNORMAL,Locale.CHINESE).format(date);
    }
    
    public static String time2Format(Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(TIME2).format(date);
    }
    public static String format(String format,Date date){
    	if(date == null){
    		return "";
    	}
    	return new SimpleDateFormat(format).format(date);
    }
    
}
